<!DOCTYPE html>

































































<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="shortcut icon" type="image/x-icon" href="../../../favicon.ico" />
<title>Providing Resources | Android Developers</title>
<link href="../../../assets/android-developer-docs-devguide.css" rel="stylesheet" type="text/css" />
<script src="../../../assets/search_autocomplete.js" type="text/javascript"></script>
<script src="../../../assets/jquery-resizable.min.js" type="text/javascript"></script>
<script src="../../../assets/android-developer-docs.js" type="text/javascript"></script>
<script src="../../../assets/prettify.js" type="text/javascript"></script>
<script type="text/javascript">
  setToRoot("../../../");
</script>
<noscript>
  <style type="text/css">
    html,body{overflow:auto;}
    #body-content{position:relative; top:0;}
    #doc-content{overflow:visible;border-left:3px solid #666;}
    #side-nav{padding:0;}
    #side-nav .toggle-list ul {display:block;}
    #resize-packages-nav{border-bottom:3px solid #666;}
  </style>
</noscript>
</head>
<body class="gc-documentation">

  <div id="header">
      <div id="headerLeft">
          <a href="../../../index.html" tabindex="-1"><img
              src="../../../assets/images/bg_logo.png" alt="Android Developers" /></a>
          <ul id="header-tabs" class="guide">
    
	<li id="home-link"><a href="../../../offline.html">
	
		<span class="en">Home</span>
		<span style="display:none" class="de">Startseite</span>
		<span style="display:none" class="es"></span>
		<span style="display:none" class="fr"></span>
		<span style="display:none" class="it"></span>
		<span style="display:none" class="ja">ホーム</span>
		<span style="display:none" class="zh-CN">主页</span>
		<span style="display:none" class="zh-TW">首頁</span>
	
	</a></li>
	<li id="sdk-link"><a href="../../../sdk/index.html">
		<span class="en">SDK</span>
	</a></li>
	<li id="guide-link"><a href="../../../guide/index.html" onClick="return loadLast('guide')">
	
		<span class="en">Dev Guide</span>
		<span style="display:none" class="de">Handbuch</span>
		<span style="display:none" class="es">Guía</span>
		<span style="display:none" class="fr">Guide</span>
		<span style="display:none" class="it">Guida</span>
		<span style="display:none" class="ja">開発ガイド</span>
		<span style="display:none" class="zh-CN">开发人员指南</span>
		<span style="display:none" class="zh-TW">開發指南</span>
	
	</a></li>
	<li id="reference-link"><a href="../../../reference/packages.html" onClick="return loadLast('reference')">
	
		<span class="en">Reference</span>
		<span style="display:none" class="de">Referenz</span>
		<span style="display:none" class="es">Referencia</span>
		<span style="display:none" class="fr">Référence</span>
		<span style="display:none" class="it">Riferimento</span>
		<span style="display:none" class="ja">リファレンス</span>
		<span style="display:none" class="zh-CN">参考</span>
		<span style="display:none" class="zh-TW">參考資料</span>
	
	</a></li>
	<li id="resources-link"><a href="../../../resources/index.html" onClick="return loadLast('resources')">
	
		<span class="en">Resources</span>
		<span style="display:none" class="de"></span>
		<span style="display:none" class="es"></span>
		<span style="display:none" class="fr"></span>
		<span style="display:none" class="it"></span>
    		<span style="display:none" class="ja"></span>
		<span style="display:none" class="zh-CN"></span>
		<span style="display:none" class="zh-TW"></span>
	
	</a></li>
	<li id="videos-link"><a href="../../../videos/index.html" onClick="return loadLast('videos')">
	
		<span class="en">Videos</span>
		<span style="display:none" class="de"></span>
		<span style="display:none" class="es"></span>
		<span style="display:none" class="fr"></span>
		<span style="display:none" class="it"></span>
		<span style="display:none" class="ja">ビデオ</span>
		<span style="display:none" class="zh-CN"></span>
		<span style="display:none" class="zh-TW"></span>
	
	</a></li>
	<li><a href="http://android-developers.blogspot.com" onClick="return requestAppendHL(this.href)">
	
		<span class="en">Blog</span>
		<span style="display:none" class="de"></span>
		<span style="display:none" class="es"></span>
		<span style="display:none" class="fr"></span>
		<span style="display:none" class="it"></span>
		<span style="display:none" class="ja">ブログ</span>
		<span style="display:none" class="zh-CN">博客</span>
		<span style="display:none" class="zh-TW">網誌</span>
	
	</a></li>


     
</ul>
     
      </div>
      <div id="headerRight">
          <div id="headerLinks">
          
          <a href="http://www.android.com">Android.com</a>
          </div>
  <div id="search" >
      <div id="searchForm">
          <form accept-charset="utf-8" class="gsc-search-box" 
                onsubmit="return submit_search()">
            <table class="gsc-search-box" cellpadding="0" cellspacing="0"><tbody>
                <tr>
                  <td class="gsc-input">
                    <input id="search_autocomplete" class="gsc-input" type="text" size="33" autocomplete="off"
                      title="search developer docs" name="q"
                      value="search developer docs"
                      onFocus="search_focus_changed(this, true)"
                      onBlur="search_focus_changed(this, false)"
                      onkeydown="return search_changed(event, true, '../../../')"
                      onkeyup="return search_changed(event, false, '../../../')" />
                  <div id="search_filtered_div" class="no-display">
                      <table id="search_filtered" cellspacing=0>
                      </table>
                  </div>
                  </td>
                  <td class="gsc-search-button">
                    <input type="submit" value="Search" title="search" id="search-button" class="gsc-search-button" />
                  </td>
                  <td class="gsc-clear-button">
                    <div title="clear results" class="gsc-clear-button">&nbsp;</div>
                  </td>
                </tr></tbody>
              </table>
          </form>
      </div><!-- searchForm -->
  </div><!-- search -->
      </div><!-- headerRight -->
      <script type="text/javascript">
        <!--  
        changeTabLang(getLangPref());
        //-->
      </script>
  </div><!-- header -->

  <div class="g-section g-tpl-240" id="body-content">
    <div class="g-unit g-first" id="side-nav">
      <div id="devdoc-nav">
<ul>

  <li>
    <h2><span class="en">Android Basics</span>
        <span class="de" style="display:none">Einführung in Android</span>
        <span class="es" style="display:none">Información básica sobre Android</span>
        <span class="fr" style="display:none">Présentation d'Android</span>
        <span class="it" style="display:none">Nozioni di base su Android</span>
        <span class="ja" style="display:none">Android の基本</span>
        <span class="zh-CN" style="display:none">Android 基础知识</span>
        <span class="zh-TW" style="display:none">Android 簡介</span>
    </h2>
    <ul>
      <li><a href="../../../guide/basics/what-is-android.html">
        <span class="en">What Is Android?</span>
        <span class="de" style="display:none">Was ist Android?</span>
        <span class="es" style="display:none">¿Qué es Android?</span>
        <span class="fr" style="display:none">Qu'est-ce qu'Android&nbsp;?</span>
        <span class="it" style="display:none">Che cos'è Android?</span>
        <span class="ja" style="display:none">Android とは</span>
        <span class="zh-CN" style="display:none">Android 是什么？</span>
        <span class="zh-TW" style="display:none">什麼是 Android？</span>
          </a></li>
      <li><a href="../../../guide/topics/fundamentals.html">
        <span class="en">Application Fundamentals</span>
        <span class="de" style="display:none">Anwendungsgrundlagen</span>
        <span class="es" style="display:none">Fundamentos de las aplicaciones</span>
        <span class="fr" style="display:none">Principes de base des applications</span>
        <span class="it" style="display:none">Concetti fondamentali sulle applicazioni</span>
        <span class="ja" style="display:none">開発の基礎</span>
        <span class="zh-CN" style="display:none">应用程序基础</span>
        <span class="zh-TW" style="display:none">應用程式基本原理</span>
      </a></li>

  <!--  <li><a style="color:gray;">The Android SDK</a></li> -->
  <!--  <li><a style="color:gray;">Walkthrough for Developers</a></li> -->
      <!-- quick overview of what it's like to develop on Android -->
    </ul>
  </li>

  <li>
    <h2>
      <span class="en">Framework Topics</span>
      <span class="de" style="display:none">Framework-Themen</span>
      <span class="es" style="display:none">Temas sobre el framework</span>
      <span class="fr" style="display:none">Thèmes relatifs au framework</span>
      <span class="it" style="display:none">Argomenti relativi al framework</span>
      <span class="ja" style="display:none">フレームワーク トピック</span>
      <span class="zh-CN" style="display:none">框架主题</span>
      <span class="zh-TW" style="display:none">架構主題</span>
    </h2>
    <ul>
      <li class="toggle-list">
        <div><a href="../../../guide/topics/fundamentals/activities.html">
          <span class="en">Activities</span>
        </a></div>
        <ul>
          <li><a href="../../../guide/topics/fundamentals/fragments.html">
            <span class="en">Fragments</span>
          </a></li>
          <li><a href="../../../guide/topics/fundamentals/loaders.html">
            <span class="en">Loaders</span>
          </a></li>
          <li><a href="../../../guide/topics/fundamentals/tasks-and-back-stack.html">
            <span class="en">Tasks and Back Stack</span></a></li>
        </ul>
      </li>
      <li class="toggle-list">
        <div><a href="../../../guide/topics/fundamentals/services.html">
          <span class="en">Services</span>
        </a></div>
        <ul>
          <li><a href="../../../guide/topics/fundamentals/bound-services.html">
            <span class="en">Bound Services</span>
          </a></li>
        </ul>
      </li>
      <li><a href="../../../guide/topics/providers/content-providers.html">
            <span class="en">Content Providers</span>
          </a></li>
      <li><a href="../../../guide/topics/intents/intents-filters.html">
            <span class="en">Intents and Intent Filters</span>
          </a></li>
      <li><a href="../../../guide/topics/fundamentals/processes-and-threads.html">
            <span class="en">Processes and Threads</span>
          </a></li>
    </ul>


    <ul>
      <li class="toggle-list">
        <div><a href="../../../guide/topics/ui/index.html">
            <span class="en">User Interface</span>
          </a></div>
        <ul>
          <li><a href="../../../guide/topics/ui/declaring-layout.html">
               <span class="en">XML Layouts</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/ui-events.html">
                <span class="en">Input Events</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/menus.html">
               <span class="en">Menus</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/actionbar.html">
               <span class="en">Action Bar</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/dialogs.html">
                <span class="en">Dialogs</span>
              </a></li>
          <li class="toggle-list">
            <div><a href="../../../guide/topics/ui/notifiers/index.html">
                <span class="en">Notifications</span>
            </a></div>
            <ul>
              <li><a href="../../../guide/topics/ui/notifiers/toasts.html">
                <span class="en">Toast Notifications</span>
              </a></li>
              <li><a href="../../../guide/topics/ui/notifiers/notifications.html">
                <span class="en">Status Bar Notifications</span>
              </a></li>
            </ul>
          </li>
          <li><a href="../../../guide/topics/ui/drag-drop.html">
                <span class="en">Drag and Drop</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/themes.html">
                <span class="en">Styles and Themes</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/custom-components.html">
                <span class="en">Custom Components</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/binding.html">
                <span class="en">Binding to Data with AdapterView</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/layout-objects.html">
                <span class="en">Common Layout Objects</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/how-android-draws.html">
                <span class="en">How Android Draws Views</span>
              </a></li>
        </ul>
      </li><!-- end of User Interface -->

      <li class="toggle-list">
        <div><a href="../../../guide/topics/resources/index.html">
               <span class="en">Application Resources</span>
             </a></div>
        <ul>
          <li><a href="../../../guide/topics/resources/providing-resources.html">
                <span class="en">Providing Resources</span>
              </a></li>
          <li><a href="../../../guide/topics/resources/accessing-resources.html">
                <span class="en">Accessing Resources</span>
              </a></li>
          <li><a href="../../../guide/topics/resources/runtime-changes.html">
                <span class="en">Handling Runtime Changes</span>
              </a></li>
          <li><a href="../../../guide/topics/resources/localization.html">
                <span class="en">Localization</span>
              </a></li>
          <li class="toggle-list">
            <div><a href="../../../guide/topics/resources/available-resources.html">
              <span class="en">Resource Types</span>
            </a></div>
            <ul>
              <li><a href="../../../guide/topics/resources/animation-resource.html">Animation</a></li>
              <li><a href="../../../guide/topics/resources/color-list-resource.html">Color State List</a></li>
              <li><a href="../../../guide/topics/resources/drawable-resource.html">Drawable</a></li>
              <li><a href="../../../guide/topics/resources/layout-resource.html">Layout</a></li>
              <li><a href="../../../guide/topics/resources/menu-resource.html">Menu</a></li>
              <li><a href="../../../guide/topics/resources/string-resource.html">String</a></li>
              <li><a href="../../../guide/topics/resources/style-resource.html">Style</a></li>
              <li><a href="../../../guide/topics/resources/more-resources.html">More Types</a></li>
            </ul>
          </li><!-- end of resource types -->
        </ul>
      </li><!-- end of app resources -->
      <li class="toggle-list">
        <div><a href="../../../guide/topics/data/data-storage.html">
            <span class="en">Data Storage</span>
          </a></div>
          <ul>
            <li><a href="../../../guide/topics/data/backup.html">
                <span class="en">Data Backup</span>
              </a>
            </li>
          </ul>
      </li>
      <li><a href="../../../guide/topics/security/security.html">
            <span class="en">Security and Permissions</span>
          </a></li>
      <li class="toggle-list">
        <div><a href="../../../guide/topics/manifest/manifest-intro.html">
          <span class="en">The AndroidManifest.xml File</span>
        </a></div>
        <ul>
          <li><a href="../../../guide/topics/manifest/action-element.html">&lt;action&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/activity-element.html">&lt;activity&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/activity-alias-element.html">&lt;activity-alias&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/application-element.html">&lt;application&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/category-element.html">&lt;category&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/compatible-screens-element.html">&lt;compatible-screens&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/data-element.html">&lt;data&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/grant-uri-permission-element.html">&lt;grant-uri-permission&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/instrumentation-element.html">&lt;instrumentation&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/intent-filter-element.html">&lt;intent-filter&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/meta-data-element.html">&lt;meta-data&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/path-permission-element.html">&lt;path-permission&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/permission-element.html">&lt;permission&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/permission-group-element.html">&lt;permission-group&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/permission-tree-element.html">&lt;permission-tree&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/provider-element.html">&lt;provider&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/receiver-element.html">&lt;receiver&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/service-element.html">&lt;service&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/supports-gl-texture-element.html">&lt;supports-gl-texture&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/supports-screens-element.html">&lt;supports-screens&gt;</a></li><!-- ##api level 4## -->
          <li><a href="../../../guide/topics/manifest/uses-configuration-element.html">&lt;uses-configuration&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/uses-feature-element.html">&lt;uses-feature&gt;</a></li> <!-- ##api level 4## -->
          <li><a href="../../../guide/topics/manifest/uses-library-element.html">&lt;uses-library&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/uses-permission-element.html">&lt;uses-permission&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/uses-sdk-element.html">&lt;uses-sdk&gt;</a></li>
        </ul>
      </li><!-- end of the manifest file -->
    </ul>

    <ul>
    <li class="toggle-list">
        <div><a href="../../../guide/topics/graphics/index.html">
            <span class="en">Graphics</span>
          </a><span class="new-child">new!</span></div>
        <ul>
          <li><a href="../../../guide/topics/graphics/2d-graphics.html">
              <span class="en">Canvas and Drawables</span></a></li>
          <li><a href="../../../guide/topics/graphics/hardware-accel.html">
              <span class="en">Hardware Acceleration</span></a>
            <span class="new">new!</span></li>
          <li><a href="../../../guide/topics/graphics/opengl.html">
              <span class="en">OpenGL</span>
            </a><span class="new">updated</span></li>
        </ul>
      </li>
      <li class="toggle-list">
        <div><a href="../../../guide/topics/graphics/animation.html">
            <span class="en">Animation</span>
          </a></div>
        <ul>
          <li><a href="../../../guide/topics/graphics/prop-animation.html">
              <span class="en">Property Animation</span></a></li>
          <li><a href="../../../guide/topics/graphics/view-animation.html">
              <span class="en">View Animation</span></a></li>
          <li><a href="../../../guide/topics/graphics/drawable-animation.html">
              <span class="en">Drawable Animation</span></a></li>
        </ul>
      </li>
      <li class="toggle-list">
	        <div><a href="../../../guide/topics/renderscript/index.html">
	            <span class="en">RenderScript</span>
	          </a></div>
	        <ul>
	          <li><a href="../../../guide/topics/renderscript/graphics.html">
	                <span class="en">Graphics</span>
	              </a>
	          </li>
	          <li><a href="../../../guide/topics/renderscript/compute.html">
	                <span class="en">Compute</span>
	              </a>
	          </li>
	        </ul>
  	  </li>

      <li class="toggle-list">
          <div><a href="../../../guide/topics/media/index.html">
            <span class="en">Multimedia and Camera</span>
          </a><span class="new">updated</span></div>
          <ul>
            <li><a href="../../../guide/topics/media/mediaplayer.html">
                  <span class="en">Media Playback</span></a>
                </li>
            <li><a href="../../../guide/topics/media/jetplayer.html">
                  <span class="en">JetPlayer</span></a>
                </li>
            <li><a href="../../../guide/topics/media/camera.html">
                  <span class="en">Camera</span></a>
                  <span class="new">new!</span>
                </li>
            <li><a href="../../../guide/topics/media/audio-capture.html">
                  <span class="en">Audio Capture</span></a>
                </li>
          </ul>
      </li>
      <li>
        <a href="../../../guide/topics/clipboard/copy-paste.html">
            <span class="en">Copy and Paste</span>
        </a></li>
  <!--<li class="toggle-list">
        <div><a style="color:gray;">Sensors</a></div>
          <ul>
            <li><a style="color:gray;">Camera</a></li>
            <li><a style="color:gray;">Compass</a></li>
            <li><a style="color:gray;">Accelerometer</a></li>
          </ul>
      </li> -->
      <li class="toggle-list">
        <div><a href="../../../guide/topics/location/index.html">
               <span class="en">Location and Maps</span>
             </a></div>
        <ul>
          <li><a href="../../../guide/topics/location/obtaining-user-location.html">
                <span class="en">Obtaining User Location</span>
              </a></li>
        </ul>
      </li>
  <!--<li class="toggle-list">
        <div><a style="color:gray;">Wireless Controls</a></div>
          <ul>
            <li><a style="color:gray;">Wi-Fi</a></li>
          </ul>
      </li> -->
  <!--<li><a style="color:gray;">Localization</a></li>  -->
      <li><a href="../../../guide/topics/appwidgets/index.html">
            <span class="en">App Widgets</span></a>
          </li>
      <li><a href="../../../guide/topics/wireless/bluetooth.html">
            <span class="en">Bluetooth</span></a>
          </li>
      <li><a href="../../../guide/topics/nfc/index.html">
            <span class="en">Near Field Communication</span>
          </a></li>
      <li class="toggle-list">
          <div><a href="../../../guide/topics/usb/index.html">
            <span class="en">USB</span></a>
          </div>
            <ul>
              <li><a href="../../../guide/topics/usb/accessory.html">Accessory</a></li>
              <li><a href="../../../guide/topics/usb/host.html">Host</a></li>
              <li><a href="../../../guide/topics/usb/adk.html">Open Accessory Dev Kit</a></li>
            </ul>
          </li>

       <li><a href="../../../guide/topics/network/sip.html">
            <span class="en">Session Initiation Protocol</span>
          </a></li>
      <li class="toggle-list">
        <div><a href="../../../guide/topics/search/index.html">
            <span class="en">Search</span>
          </a></div>
          <ul>
            <li><a href="../../../guide/topics/search/search-dialog.html">Creating a Search Interface</a></li>
            <li><a href="../../../guide/topics/search/adding-recent-query-suggestions.html">Adding Recent Query Suggestions</a></li>
            <li><a href="../../../guide/topics/search/adding-custom-suggestions.html">Adding Custom Suggestions</a></li>
            <li><a href="../../../guide/topics/search/searchable-config.html">Searchable Configuration</a></li>
          </ul>
      </li>
      <li><a href="../../../guide/topics/admin/device-admin.html">
            <span class="en">Device Administration</span></a>
      </li>
      <li class="toggle-list">
           <div>
                <a href="../../../guide/topics/testing/index.html">
                   <span class="en">Testing</span>
               </a>
           </div>
           <ul>
              <li>
                <a href="../../../guide/topics/testing/testing_android.html">
                <span class="en">Testing Fundamentals</span></a>
              </li>
              <li>
                <a href="../../../guide/topics/testing/activity_testing.html">
                <span class="en">Activity Testing</span></a>
              </li>
              <li>
                <a href="../../../guide/topics/testing/contentprovider_testing.html">
                <span class="en">Content Provider Testing</span></a>
              </li>
              <li>
                <a href="../../../guide/topics/testing/service_testing.html">
                <span class="en">Service Testing</span></a>
              </li>
              <li>
                <a href="../../../guide/topics/testing/what_to_test.html">
                <span class="en">What To Test</span></a>
              </li>
           </ul>
      </li>
    </ul>
  </li>

  <li>
    <h2>
      <span class="en">Android Market Topics</span>
    </h2>
    <ul>
      <li><a href="../../../guide/publishing/licensing.html">
          <span class="en">Application Licensing</span></a>
      </li>
      <li class="toggle-list">
        <div><a href="../../../guide/market/billing/index.html">
            <span class="en">In-app Billing</span></a>
        </div>
        <ul>
          <li><a href="../../../guide/market/billing/billing_overview.html">
              <span class="en">In-app Billing Overview</span></a>
          </li>
          <li><a href="../../../guide/market/billing/billing_integrate.html">
              <span class="en">Implementing In-app Billing</span></a>
          </li>
          <li><a href="../../../guide/market/billing/billing_best_practices.html">
              <span class="en">Security and Design</span></a>
          </li>
          <li><a href="../../../guide/market/billing/billing_testing.html">
              <span class="en">Testing In-app Billing</span></a>
          </li>
          <li><a href="../../../guide/market/billing/billing_admin.html">
              <span class="en">Administering In-app Billing</span></a>
          </li>
          <li><a href="../../../guide/market/billing/billing_reference.html">
              <span class="en">In-app Billing Reference</span></a>
          </li>
        </ul>
      </li>
      <li><a href="../../../guide/appendix/market-filters.html">
          <span class="en">Market Filters</span></a>
      </li>
      <li><a href="../../../guide/market/publishing/multiple-apks.html">
          <span class="en">Multiple APK Support</span></a>
      </li>
    </ul>
  </li>


  <li>
    <h2><span class="en">Developing</span>
               <span class="de" style="display:none">Entwicklung</span>
               <span class="es" style="display:none">Desarrollo</span>
               <span class="fr" style="display:none">Développement</span>
               <span class="it" style="display:none">Sviluppo</span>
               <span class="ja" style="display:none">開発</span>
               <span class="zh-CN" style="display:none">开发</span>
               <span class="zh-TW" style="display:none">開發</span>
    </h2>
    <ul>
  <!--<li><a href="">Developing for Android</a></li>
      signing, upgrading, selecting a package name, select device profile, touch, trackball, dpad available, etc. -->
      <li>
        <a href="../../../guide/developing/index.html">
        <span class="en">Introduction</span></a>
      </li>

      <li class="toggle-list">
        <div>
           <a href="../../../guide/developing/devices/index.html">
                <span class="en">Managing Virtual Devices</span>
            </a>
        </div>
        <ul>
          <li>
            <a href="../../../guide/developing/devices/managing-avds.html">
              <span class="en">With AVD Manager</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/devices/managing-avds-cmdline.html">
              <span class="en">From the Command Line</span>
            </a>
          </li>
          <li>
           <a href="../../../guide/developing/devices/emulator.html">
                <span class="en">Using the Android Emulator</span>
            </a>
          </li>
        </ul>
      </li>
      <li>
        <a href="../../../guide/developing/device.html">
          <span class="en">Using Hardware Devices</span>
        </a>
      </li>

      <li class="toggle-list">
        <div>
          <a href="../../../guide/developing/projects/index.html">
            <span class="en">Managing Projects</span>
          </a>
        </div>
        <ul>
          <li>
            <a href="../../../guide/developing/projects/projects-eclipse.html">
              <span class="en">From Eclipse with ADT</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/projects/projects-cmdline.html">
                <span class="en">From the Command Line</span>
            </a>
          </li>
        </ul>
      </li>

      <li class="toggle-list">
        <div>
          <a href="../../../guide/developing/building/index.html">
            <span class="en">Building and Running</span>
          </a>
        </div>
        <ul>
          <li><a href="../../../guide/developing/building/building-eclipse.html">
            <span class="en">From Eclipse with ADT</span>
          </a></li>
          <li><a href="../../../guide/developing/building/building-cmdline.html">
            <span class="en">From the Command Line</span></a></li>
        </ul>
      </li>

      <li class="toggle-list">
        <div>
          <a href="../../../guide/developing/debugging/index.html">
            <span class="en">Debugging</span>
          </a>
        </div>
        <ul>
          <li>
            <a href="../../../guide/developing/debugging/debugging-projects.html">
                <span class="en">From Eclipse with ADT</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/debugging/debugging-projects-cmdline.html">
                <span class="en">From Other IDEs</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/debugging/ddms.html">
              <span class="en">Using DDMS</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/debugging/debugging-log.html">
                <span class="en">Reading and Writing Logs</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/debugging/debugging-ui.html">
                <span class="en">Debugging and Profiling UIs</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/debugging/debugging-tracing.html">
                <span class="en">Profiling with Traceview and dmtracedump</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/debugging/debugging-devtools.html">
                <span class="en">Using the Dev Tools App</span>
            </a>
          </li>
        </ul>
      </li>

      <li class="toggle-list">
           <div>
                <a href="../../../guide/developing/testing/index.html">
                   <span class="en">Testing</span>
               </a>
           </div>
           <ul>
              <li>
                <a href="../../../guide/developing/testing/testing_eclipse.html">
                  <span class="en">From Eclipse with ADT</span>
                </a>
              </li>

              <li>
                <a href="../../../guide/developing/testing/testing_otheride.html">
                  <span class="en">From Other IDEs</span>
                </a>
              </li>
           </ul>
         </li>

         <li class="toggle-list">
        <div><a href="../../../guide/developing/tools/index.html">
            <span class="en">Tools</span>
          </a></div>
        <ul>
          <li><a href="../../../guide/developing/tools/adb.html">adb</a></li>
          <li><a href="../../../guide/developing/tools/adt.html">ADT</a></li>
          <li><a href="../../../guide/developing/tools/android.html">android</a></li>
          <li><a href="../../../guide/developing/tools/bmgr.html">bmgr</a>
          <li><a href="../../../guide/developing/tools/dmtracedump.html">dmtracedump</a></li>
          <li><a href="../../../guide/developing/tools/draw9patch.html">Draw
          9-Patch</a></li>
          <li><a href="../../../guide/developing/tools/emulator.html">Emulator</a></li>
          <li><a href="../../../guide/developing/tools/etc1tool.html">etc1tool</a></li>
          <li><a href="../../../guide/developing/tools/hierarchy-viewer.html">Hierarchy Viewer</a></li>
          <li><a href="../../../guide/developing/tools/hprof-conv.html">hprof-conv</a></li>
          <li><a href="../../../guide/developing/tools/layoutopt.html">layoutopt</a></li>
          <li><a href="../../../guide/developing/tools/logcat.html">logcat</a></li>
          <li><a href="../../../guide/developing/tools/mksdcard.html">mksdcard</a></li>
          <li><a href="../../../guide/developing/tools/monkey.html">Monkey</a></li>
          <li class="toggle-list">
            <div><a href="../../../guide/developing/tools/monkeyrunner_concepts.html">
              <span class="en">monkeyrunner</span>
            </a></div>
            <ul>
              <li><a href="../../../guide/developing/tools/MonkeyDevice.html">
                <span class="en">MonkeyDevice</span>
                </a></li>
              <li><a href="../../../guide/developing/tools/MonkeyImage.html">
                <span class="en">MonkeyImage</span>
                </a></li>
              <li><a href="../../../guide/developing/tools/MonkeyRunner.html">
                <span class="en">MonkeyRunner</span>
                </a></li>
            </ul>
          </li>
          <li><a href="../../../guide/developing/tools/proguard.html">ProGuard</a></li>
          <li><a href="../../../guide/developing/tools/adb.html#sqlite">sqlite3</a></li>
          <li><a href="../../../guide/developing/tools/traceview.html">Traceview</a></li>
          <li><a href="../../../guide/developing/tools/zipalign.html">zipalign</a></li>
        </ul>
      </li>
    </ul>
  </li>

  <li>
    <h2><span class="en">Publishing</span>
        <span class="de" style="display:none">Veröffentlichung</span>
        <span class="es" style="display:none">Publicación</span>
        <span class="fr" style="display:none">Publication</span>
        <span class="it" style="display:none">Pubblicazione</span>
        <span class="ja" style="display:none">公開</span>
        <span class="zh-CN" style="display:none">发布</span>
        <span class="zh-TW" style="display:none">發佈</span>
    </h2>
    <ul>
      <li><a href="../../../guide/publishing/app-signing.html">
            <span class="en">Signing Your Applications</span>
            <span class="de" style="display:none">Signieren Ihrer Anwendungen</span>
            <span class="es" style="display:none">Firma de aplicaciones</span>
            <span class="fr" style="display:none">Attribution de votre signature <br />à vos applications</span>
            <span class="it" style="display:none">Firma delle applicazioni</span>
            <span class="ja" style="display:none">アプリケーションへの署名</span>
            <span class="zh-CN" style="display:none">应用程序签名</span>
            <span class="zh-TW" style="display:none">簽署應用程式</span>
          </a></li>
      <li><a href="../../../guide/publishing/versioning.html">
            <span class="en">Versioning Your Applications</span>
            <span class="de" style="display:none">Versionsverwaltung für Ihre <br />Anwendungen</span>
            <span class="es" style="display:none">Versiones de las aplicaciones</span>
            <span class="fr" style="display:none">Attribution d'une version à vos applications</span>
            <span class="it" style="display:none">Controllo versioni delle applicazioni</span>
            <span class="ja" style="display:none">アプリケーションのバージョニング</span>
            <span class="zh-CN" style="display:none">应用程序版本控制</span>
            <span class="zh-TW" style="display:none">應用程式版本設定</span>
          </a></li>
      <li><a href="../../../guide/publishing/preparing.html">
            <span class="en">Preparing to Publish</span>
            <span class="de" style="display:none">Vorbereitung auf die Veröffentlichung</span>
            <span class="es" style="display:none">Publicación de aplicaciones</span>
            <span class="fr" style="display:none">Préparation à la publication</span>
            <span class="it" style="display:none">Preparativi per la pubblicazione</span>
            <span class="ja" style="display:none">公開の準備</span>
            <span class="zh-CN" style="display:none">准备发布</span>
            <span class="zh-TW" style="display:none">準備發佈</span>
          </a></li>
      <li><a href="../../../guide/publishing/publishing.html">
            <span class="en">Publishing on Android Market</span>
          </a></li>
    </ul>
  </li>

  <li>
    <h2><span class="en">Best Practices</span>
               <span class="de" style="display:none">Bewährte Verfahren</span>
               <span class="es" style="display:none">Prácticas recomendadas</span>
               <span class="fr" style="display:none">Meilleures pratiques</span>
               <span class="it" style="display:none">Best practice</span>
               <span class="ja" style="display:none">ベスト プラクティス</span>
               <span class="zh-CN" style="display:none">最佳实践</span>
               <span class="zh-TW" style="display:none">最佳實務</span>
    </h2>
    <ul>
      <li><a href="../../../guide/practices/compatibility.html">
            <span class="en">Compatibility</span>
          </a></li>
      <li class="toggle-list">
        <div><a href="../../../guide/practices/screens_support.html">
          <span class="en">Supporting Multiple Screens</span>
        </a></div>
        <ul>
          <li><a href="../../../guide/practices/screens-distribution.html">
            <span class="en">Distributing to Specific Screens</span>
          </a></li>
          <li><a href="../../../guide/practices/screen-compat-mode.html">
            <span class="en">Screen Compatibility Mode</span>
          </a></li>
          <li><a href="../../../guide/practices/screens-support-1.5.html">
            <span class="en">Strategies for Android 1.5</span>
          </a></li>
        </ul>
      </li>
      <li><a href="../../../guide/practices/optimizing-for-3.0.html">
            <span class="en">Optimizing Apps for Android 3.0</span>
          </a></li>
      <li class="toggle-list">
        <div><a href="../../../guide/practices/ui_guidelines/index.html">
               <span class="en">UI Guidelines</span>
             </a></div>
        <ul>
          <li class="toggle-list">
            <div><a href="../../../guide/practices/ui_guidelines/icon_design.html">
                   <span class="en">Icon Design <span class="new">updated</span></span>
                 </a></div>
            <ul>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_launcher.html">
                    <span class="en">Launcher Icons <span class="new">updated</span></span>
                  </a></li>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_menu.html">
                    <span class="en">Menu Icons</span>
                  </a></li>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_action_bar.html">
                    <span class="en">Action Bar Icons <span class="new">new!</span></span>
                  </a></li>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_status_bar.html">
                    <span class="en">Status Bar Icons <span class="new">updated</span></span>
                  </a></li>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_tab.html">
                    <span class="en">Tab Icons</span>
                  </a></li>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_dialog.html">
                    <span class="en">Dialog Icons</span>
                  </a></li>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_list.html">
                    <span class="en">List View Icons</span>
                  </a></li>
            </ul>
          </li>
          <li><a href="../../../guide/practices/ui_guidelines/widget_design.html">
                <span class="en">App Widget Design <span class="new">updated</span></span>
              </a></li>
          <li><a href="../../../guide/practices/ui_guidelines/activity_task_design.html">
                <span class="en">Activity and Task Design</span>
              </a></li>
          <li><a href="../../../guide/practices/ui_guidelines/menu_design.html">
                <span class="en">Menu Design</span>
              </a></li>
        </ul>
      </li>
      </ul>
      <ul>
      <li><a href="../../../guide/practices/design/accessibility.html">
            <span class="en">Designing for Accessibility</span>
          </a></li>
      <li class="toggle-list">
        <div><a href="../../../guide/practices/design/performance.html">
            <span class="en">Designing for Performance</span>
          </a></div>
        <ul>
          <li><a href="../../../guide/practices/design/jni.html">
                <span class="en">JNI Tips</span>
              </a></li>
        </ul>
      </li>
      <li><a href="../../../guide/practices/design/responsiveness.html">
            <span class="en">Designing for Responsiveness</span>
          </a></li>
      <li><a href="../../../guide/practices/design/seamlessness.html">
            <span class="en">Designing for Seamlessness</span>
          </a></li>
    </ul>
  </li>

  <li>
    <h2><span class="en">Web Applications</span>
    </h2>
    <ul>
      <li><a href="../../../guide/webapps/index.html">
            <span class="en">Web Apps Overview</span>
          </a></li>
      <li><a href="../../../guide/webapps/targeting.html">
            <span class="en">Targeting Screens from Web Apps</span>
          </a></li>
      <li><a href="../../../guide/webapps/webview.html">
            <span class="en">Building Web Apps in WebView</span>
          </a></li>
      <li><a href="../../../guide/webapps/debugging.html">
            <span class="en">Debugging Web Apps</span>
          </a></li>
      <li><a href="../../../guide/webapps/best-practices.html">
            <span class="en">Best Practices for Web Apps</span>
          </a></li>
    </ul>
  </li>

  <li>
    <h2><span class="en">Appendix</span>
               <span class="de" style="display:none">Anhang</span>
               <span class="es" style="display:none">Apéndice</span>
               <span class="fr" style="display:none">Annexes</span>
               <span class="it" style="display:none">Appendice</span>
               <span class="ja" style="display:none">付録</span>
               <span class="zh-CN" style="display:none">附录</span>
               <span class="zh-TW" style="display:none">附錄</span>
    </h2>
    <ul>
      <li><a href="../../../guide/appendix/api-levels.html">
            <span class="en">Android API Levels</span>
          </a></li>
      <li><a href="../../../guide/appendix/install-location.html">
            <span class="en">App Install Location</span>
          </a></li>
      <li><a href="../../../guide/appendix/media-formats.html">
            <span class="en">Supported Media Formats <span class="new">updated</span></span>
          </a></li>
      <li><a href="../../../guide/appendix/g-app-intents.html">
            <span class="en">Intents List: Google Apps</span>
          </a></li>
      <li><a href="../../../guide/developing/tools/aidl.html">AIDL</a></li>
      <li><a href="../../../guide/appendix/glossary.html">
            <span class="en">Glossary</span>
          </a></li>
    </ul>
  </li>

</ul>

<script type="text/javascript">
<!--
    buildToggleLists();
    changeNavLang(getLangPref());
//-->
</script>

      </div>
    </div> <!-- end side-nav -->
    <script>
      addLoadEvent(function() {
        scrollIntoView("devdoc-nav");
        });
    </script>




<div class="g-unit" id="doc-content"><a name="top"></a>

<div id="jd-header" class="guide-header">
  <span class="crumb">
    
      <a href="index.html">Application Resources</a> >
    
  </span>
<h1>Providing Resources</h1>
</div>

  <div id="jd-content">

    <div class="jd-descr">
    <div id="qv-wrapper">
<div id="qv">
  <h2>Quickview</h2>
  <ul>
    <li>Different types of resources belong in different subdirectories of <code>res/</code></li>
    <li>Alternative resources provide configuration-specific resource files</li>
    <li>Always include default resources so your app does not depend on specific
device configurations</li>
  </ul>
  <h2>In this document</h2>
  <ol>
    <li><a href="#ResourceTypes">Grouping Resource Types</a></li>
    <li><a href="#AlternativeResources">Providing Alternative Resources</a>
      <ol>
        <li><a href="#QualifierRules">Qualifier name rules</a></li>
        <li><a href="#AliasResources">Creating alias resources</a></li>
      </ol>
    </li>
    <li><a href="#Compatibility">Providing the Best Device Compatibility with Resources</a>
      <ol>
        <li><a href="#ScreenCompatibility">Providing screen resource compatibility for Android
1.5</a></li>
      </ol>
    </li>
    <li><a href="#BestMatch">How Android Finds the Best-matching Resource</a></li>
    <li><a href="#KnownIssues">Known Issues</a></li>
  </ol>

  <h2>See also</h2>
  <ol>
    <li><a href="accessing-resources.html">Accessing Resources</a></li>
    <li><a href="available-resources.html">Resource Types</a></li>
    <li><a href="../../../guide/practices/screens_support.html">Supporting Multiple
Screens</a></li>
  </ol>
</div>
</div>

<p>You should always externalize application resources such as images and strings from your
code, so that you can maintain them independently. You should also provide alternative resources for
specific device configurations, by grouping them in specially-named resource directories. At
runtime, Android uses uses the appropriate resource based on the current configuration. For
example, you might want to provide a different UI layout depending on the screen size or different
strings depending on the language setting.</p>

<p>Once you externalize your application resources, you can access them
using resource IDs that are generated in your project's <code>R</code> class. How to use
resources in your application is discussed in <a href="accessing-resources.html">Accessing
Resources</a>. This document shows you how to group your resources in your Android project and
provide alternative resources for specific device configurations.</p>


<h2 id="ResourceTypes">Grouping Resource Types</h2>

<p>You should place each type of resource in a specific subdirectory of your project's
<code>res/</code> directory. For example, here's the file hierarchy for a simple project:</p>

<pre class="classic no-pretty-print">
MyProject/
    src/  <span style="color:black">
        MyActivity.java  </span>
    res/
        drawable/  <span style="color:black">
            icon.png  </span>
        layout/  <span style="color:black">
            main.xml
            info.xml</span>
        values/  <span style="color:black">
            strings.xml  </span>
</pre>

<p>As you can see in this example, the <code>res/</code> directory contains all the resources (in
subdirectories): an image resource, two layout resources, and a string resource file. The resource
directory names are important and are described in table 1.</p>

<p class="table-caption" id="table1"><strong>Table 1.</strong> Resource directories
supported inside project <code>res/</code> directory.</p>

<table>
  <tr>
    <th scope="col">Directory</th>
    <th scope="col">Resource Type</th>
  </tr>

  <tr>
    <td><code>animator/</code></td>
    <td>XML files that define <a href="../../../guide/topics/graphics/animation.html">property
animations</a>.</td>
  </tr>

  <tr>
    <td><code>anim/</code></td>
    <td>XML files that define <a
href="../../../guide/topics/graphics/view-animation.html#tween-animation">tween
animations</a>. (Property animations can also be saved in this directory, but
the <code>animator/</code> directory is preferred for property animations to distinguish between the two
types.)</td>
  </tr>

  <tr>
    <td><code>color/</code></td>
    <td>XML files that define a state list of colors. See <a href="color-list-resource.html">Color
State List Resource</a></td>
  </tr>

  <tr>
    <td><code>drawable/</code></td>
    <td><p>Bitmap files (<code>.png</code>, <code>.9.png</code>, <code>.jpg</code>, <code>.gif</code>) or XML files that
are compiled into the following drawable resource subtypes:</p>
      <ul>
        <li>Bitmap files</li>
        <li>Nine-Patches (re-sizable bitmaps)</li>
        <li>State lists</li>
        <li>Shapes</li>
        <li>Animation drawables</li>
        <li>Other drawables</li>
      </ul>
      <p>See <a href="drawable-resource.html">Drawable Resources</a>.</p>
    </td>
  </tr>

  <tr>
    <td><code>layout/</code></td>
    <td>XML files that define a user interface layout.
        See <a href="layout-resource.html">Layout Resource</a>.</td>
  </tr>

  <tr>
    <td><code>menu/</code></td>
    <td>XML files that define application menus, such as an Options Menu, Context Menu, or Sub
Menu. See <a href="menu-resource.html">Menu Resource</a>.</td>
  </tr>

  <tr>
    <td><code>raw/</code></td>
    <td><p>Arbitrary files to save in their raw form. To open these resources with a raw
<code><a href="../../../reference/java/io/InputStream.html">InputStream</a></code>, call <code><a href="../../../reference/android/content/res/Resources.html#openRawResource(int)">Resources.openRawResource()</a></code> with the resource ID, which is <code>R.raw.<em>filename</em></code>.</p>
      <p>However, if you need access to original file names and file hierarchy, you might consider
saving some resources in the <code>assets/</code> directory (instead of <code>res/raw/</code>). Files in <code>assets/</code> are not given a
resource ID, so you can read them only using <code><a href="../../../reference/android/content/res/AssetManager.html">AssetManager</a></code>.</p></td>
  </tr>

  <tr>
    <td><code>values/</code></td>
    <td><p>XML files that contain simple values, such as strings, integers, and colors.</p>
      <p>Whereas XML resource files in other <code>res/</code> subdirectories define a single resource
based on the XML filename, files in the <code>values/</code> directory describe multiple resources.
For a file in this directory, each child of the <code>&lt;resources&gt;</code> element defines a single
resource. For example, a <code>&lt;string&gt;</code> element creates an
<code>R.string</code> resource and a  <code>&lt;color&gt;</code> element creates an <code>R.color</code>
resource.</p>
      <p>Because each resource is defined with its own XML element, you can name the file
whatever you want and place different resource types in one file. However, for clarity, you might
want to place unique resource types in different files. For example, here are some filename
conventions for resources you can create in this directory:</p>
      <ul>
        <li>arrays.xml for resource arrays (<a
href="more-resources.html#TypedArray">typed arrays</a>).</li>
        <li>colors.xml for <a
href="more-resources.html#Color">color values</a></li>
        <li>dimens.xml for <a
href="more-resources.html#Dimension">dimension values</a>.</li>
        <li>strings.xml for <a href="string-resource.html">string
values</a>.</li>
        <li>styles.xml for <a href="style-resource.html">styles</a>.</li>
      </ul>
      <p>See <a href="string-resource.html">String Resources</a>,
        <a href="style-resource.html">Style Resource</a>, and
        <a href="more-resources.html">More Resource Types</a>.</p>
    </td>
  </tr>

  <tr>
    <td><code>xml/</code></td>
    <td>Arbitrary XML files that can be read at runtime by calling <code><a href="../../../reference/android/content/res/Resources.html#getXml(int)">Resources.getXML()</a></code>. Various XML configuration files
must be saved here, such as a <a
href="../../../guide/topics/search/searchable-config.html">searchable configuration</a>.
<!-- or preferences configuration. --></td>
  </tr>
</table>

<p class="caution"><strong>Caution:</strong> Never save resource files directly inside the
<code>res/</code> directory&mdash;it will cause a compiler error.</p>

<p>For more information about certain types of resources, see the <a
href="available-resources.html">Resource Types</a> documentation.</p>

<p>The resources that you save in the subdirectories defined in table 1 are your "default"
resources. That is, these resources define the default design and content for your application.
However, different types of Android-powered devices might call for different types of resources.
For example, if a device has a larger than normal screen, then you should provide
different layout resources that take advantage of the extra screen space. Or, if a device has a
different language setting, then you should provide different string resources that translate the
text in your user interface. To provide these different resources for different device
configurations, you need to provide alternative resources, in addition to your default
resources.</p>


<h2 id="AlternativeResources">Providing Alternative Resources</h2>


<div class="figure" style="width:421px">
<img src="../../../images/resources/resource_devices_diagram2.png" height="137" alt="" />
<p class="img-caption">
<strong>Figure 1.</strong> Two different devices, one using alternative resources.</p>
</div>

<p>Almost every application should provide alternative resources to support specific device
configurations. For instance, you should include alternative drawable resources for different
screen densities and alternative string resources for different languages. At runtime, Android
detects the current device configuration and loads the appropriate
resources for your application.</p>

<p>To specify configuration-specific alternatives for a set of resources:</p>
<ol>
  <li>Create a new directory in <code>res/</code> named in the form <code><em>&lt;resources_name&gt;</em>-<em>&lt;config_qualifier&gt;</em></code>.
    <ul>
      <li><em><code>&lt;resources_name&gt;</code></em> is the directory name of the corresponding default
resources (defined in table 1).</li>
      <li><em><code>&lt;qualifier&gt;</code></em> is a name that specifies an individual configuration
for which these resources are to be used (defined in table 2).</li>
    </ul>
    <p>You can append more than one <em><code>&lt;qualifier&gt;</code></em>. Separate each
one with a dash.</p>
  </li>
  <li>Save the respective alternative resources in this new directory. The resource files must be
named exactly the same as the default resource files.</li>
</ol>

<p>For example, here are some default and alternative resources:</p>

<pre class="classic no-pretty-print">
res/
    drawable/   <span style="color:black">
        icon.png
        background.png    </span>
    drawable-hdpi/  <span style="color:black">
        icon.png
        background.png  </span>
</pre>

<p>The <code>hdpi</code> qualifier indicates that the resources in that directory are for devices with a
high-density screen. The images in each of these drawable directories are sized for a specific
screen density, but the filenames are exactly
the same. This way, the resource ID that you use to reference the <code>icon.png</code> or <code>background.png</code> image is always the same, but Android selects the
version of each resource that best matches the current device, by comparing the device
configuration information with the qualifiers in the alternative resource directory name.</p>

<p>Android supports several configuration qualifiers and you can
add multiple qualifiers to one directory name, by separating each qualifier with a dash. Table 2
lists the valid configuration qualifiers, in order of precedence&mdash;if you use multiple
qualifiers for one resource directory, they must be added to the directory name in the order they
are listed in the table.</p>

<p class="note"><strong>Note:</strong> Some configuration qualifiers were added after Android 1.0,
so not
all versions of Android support all the qualifiers listed in table 2. New qualifiers
indicate the version in which they were added. To avoid any issues, always include a set of default
resources for resources that your application uses. For more information, see the section about <a
href="#Compatibility">Providing the Best Device Compatibility with Resources</a>.</p>

<p class="table-caption" id="table2"><strong>Table 2.</strong> Configuration qualifier
names.</p>
<table>
    <tr>
        <th>Configuration</th>
        <th>Qualifier Values</th>
        <th>Description</th>
    </tr>
    <tr id="MccQualifier">
      <td>MCC and MNC</td>
      <td>Examples:<br/>
        <code>mcc310</code><br/>
        <code><nobr>mcc310-mnc004</nobr></code><br/>
        <code>mcc208-mnc00</code><br/>
        etc.
      </td>
      <td>
        <p>The mobile country code (MCC), optionally followed by mobile network code (MNC)
        from the SIM card in the device. For example, <code>mcc310</code> is U.S. on any carrier,
        <code>mcc310-mnc004</code> is U.S. on Verizon, and <code>mcc208-mnc00</code> is France on
        Orange.</p>
        <p>If the device uses a radio connection (GSM phone), the MCC comes
        from the SIM, and the MNC comes from the network to which the
        device is connected.</p>
        <p>You can also use the MCC alone (for example, to include country-specific legal
resources in your application). If you need to specify based on the language only, then use the
<em>language and region</em> qualifier instead (discussed next). If you decide to use the MCC and
MNC qualifier, you should do so with care and test that it works as expected.</p>
        <p>Also see the configuration fields <code><a href="../../../reference/android/content/res/Configuration.html#mcc">mcc</a></code>, and <code><a href="../../../reference/android/content/res/Configuration.html#mnc">mnc</a></code>, which indicate the current mobile country code
and mobile network code, respectively.</p>
      </td>
    </tr>
    <tr id="LocaleQualifier">
      <td>Language and region</td>
      <td>Examples:<br/>
        <code>en</code><br/>
        <code>fr</code><br/>
        <code>en-rUS</code><br/>
        <code>fr-rFR</code><br/>
        <code>fr-rCA</code><br/>
        etc.
      </td>
      <td><p>The language is defined by a two-letter <a
href="http://www.loc.gov/standards/iso639-2/php/code_list.php">ISO
              639-1</a> language code, optionally followed by a two letter
              <a
href="http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html">ISO
              3166-1-alpha-2</a> region code (preceded by lowercase &quot;<code>r</code>&quot;).
        </p><p>
        The codes are <em>not</em> case-sensitive; the <code>r</code> prefix is used to
        distinguish the region portion.
        You cannot specify a region alone.</p>
        <p>This can change during the life
of your application if the user changes his or her language in the system settings. See <a
href="runtime-changes.html">Handling Runtime Changes</a> for information about
how this can affect your application during runtime.</p>
        <p>See <a href="localization.html">Localization</a> for a complete guide to localizing
your application for other languages.</p>
        <p>Also see the <code><a href="../../../reference/android/content/res/Configuration.html#locale">locale</a></code> configuration field, which
indicates the current locale.</p>
      </td>
    </tr>
    <tr id="SmallestScreenWidthQualifier">
      <td>smallestWidth</td>
      <td><code>sw&lt;N&gt;dp</code><br/><br/>
        Examples:<br/>
        <code>sw320dp</code><br/>
        <code>sw600dp</code><br/>
        <code>sw720dp</code><br/>
        etc.
      </td>
      <td>
        <p>The fundamental size of a screen, as indicated by the shortest dimension of the available
screen area. Specifically, the device's smallestWidth is the shortest of the screen's available
height and width (you may also think of it as the "smallest possible width" for the screen). You can
use this qualifier to ensure that, regardless of the screen's current orientation, your
application's has at least <code>&lt;N&gt;</code> dps of width available for it UI.</p>
        <p>For example, if your layout requires that its smallest dimension of screen area be at
least 600 dp at all times, then you can use this qualifer to create the layout resources, <code>res/layout-sw600dp/</code>. The system will use these resources only when the smallest dimension of
available screen is at least 600dp, regardless of whether the 600dp side is the user-perceived
height or width. The smallestWidth is a fixed screen size characteristic of the device; <strong>the
device's smallestWidth does not change when the screen's orientation changes</strong>.</p>
        <p>The smallestWidth of a device takes into account screen decorations and system UI. For
example, if the device has some persistent UI elements on the screen that account for space along
the axis of the smallestWidth, the system declares the smallestWidth to be smaller than the actual
screen size, because those are screen pixels not available for your UI. Thus, the value you use
should be the actual smallest dimension <em>required by your layout</em> (usually, this value is the
"smallest width" that your layout supports, regardless of the screen's current orientation).</p>
        <p>Some values you might use here for common screen sizes:</p>
        <ul>
          <li>320, for devices with screen configurations such as:
            <ul>
              <li>240x320 ldpi (QVGA handset)</li>
              <li>320x480 mdpi (handset)</li>
              <li>480x800 hdpi (high density handset)</li>
            </ul>
          </li>
          <li>480, for screens such as 480x800 mdpi (tablet/handset).</li>
          <li>600, for screens such as 600x1024 mdpi (7" tablet).</li>
          <li>720, for screens such as 720x1280 mdpi (10" tablet).</li>
        </ul>
        <p>When your application provides multiple resource directories with different values for
        the smallestWidth qualifier, the system uses the one closest to (without exceeding) the
device's smallestWidth. </p>
        <p><em>Added in API level 13.</em></p>
        <p>Also see the <a
href="../../../guide/topics/manifest/supports-screens-element.html#requiresSmallest"><code>android:requiresSmallestWidthDp</code></a> attribute, which declares the minimum smallestWidth with which
your application is compatible, and the <code><a href="../../../reference/android/content/res/Configuration.html#smallestScreenWidthDp">smallestScreenWidthDp</a></code> configuration field, which holds the
device's smallestWidth value.</p>
        <p>For more information about designing for different screens and using this
qualifier, see the <a href="../../../guide/practices/screens_support.html">Supporting
Multiple Screens</a> developer guide.</p>
      </td>
    </tr>
    <tr id="ScreenWidthQualifier">
      <td>Available width</td>
      <td><code>w&lt;N&gt;dp</code><br/><br/>
        Examples:<br/>
        <code>w720dp</code><br/>
        <code>w1024dp</code><br/>
        etc.
      </td>
      <td>
        <p>Specifies a minimum available screen width, in <code>dp</code> units at which the resource
          should be used&mdash;defined by the <code>&lt;N&gt;</code> value.  This
          configuration value will change when the orientation
          changes between landscape and portrait to match the current actual width.</p>
        <p>When your application provides multiple resource directories with different values
          for this configuration, the system uses the one closest to (without exceeding)
          the device's current screen width.  The
          value here takes into account screen decorations, so if the device has some
          persistent UI elements on the left or right edge of the display, it
          uses a value for the width that is smaller than the real screen size, accounting
          for these UI elements and reducing the application's available space.</p>
        <p><em>Added in API level 13.</em></p>
        <p>Also see the <code><a href="../../../reference/android/content/res/Configuration.html#screenWidthDp">screenWidthDp</a></code>
          configuration field, which holds the current screen width.</p>
        <p>For more information about designing for different screens and using this
qualifier, see the <a href="../../../guide/practices/screens_support.html">Supporting
Multiple Screens</a> developer guide.</p>
      </td>
    </tr>
    <tr id="ScreenHeightQualifier">
      <td>Available height</td>
      <td><code>h&lt;N&gt;dp</code><br/><br/>
        Examples:<br/>
        <code>h720dp</code><br/>
        <code>h1024dp</code><br/>
        etc.
      </td>
      <td>
        <p>Specifies a minimum available screen height, in "dp" units at which the resource
          should be used&mdash;defined by the <code>&lt;N&gt;</code> value.  This
          configuration value will change when the orientation
          changes between landscape and portrait to match the current actual height.</p>
        <p>When your application provides multiple resource directories with different values
          for this configuration, the system uses the one closest to (without exceeding)
          the device's current screen height.  The
          value here takes into account screen decorations, so if the device has some
          persistent UI elements on the top or bottom edge of the display, it uses
          a value for the height that is smaller than the real screen size, accounting
          for these UI elements and reducing the application's available space.  Screen
          decorations that are not fixed (such as a phone status bar that can be
          hidden when full screen) are <em>not</em> accounted for here, nor are
          window decorations like the title bar or action bar, so applications must be prepared to
          deal with a somewhat smaller space than they specify.
        <p><em>Added in API level 13.</em></p>
        <p>Also see the <code><a href="../../../reference/android/content/res/Configuration.html#screenHeightDp">screenHeightDp</a></code>
          configuration field, which holds the current screen width.</p>
        <p>For more information about designing for different screens and using this
qualifier, see the <a href="../../../guide/practices/screens_support.html">Supporting
Multiple Screens</a> developer guide.</p>
      </td>
    </tr>
    <tr id="ScreenSizeQualifier">
      <td>Screen size</td>
      <td>
        <code>small</code><br/>
        <code>normal</code><br/>
        <code>large</code><br/>
        <code>xlarge</code>
      </td>
      <td>
        <ul class="nolist">
        <li><code>small</code>: Screens that are of similar size to a
        low-density QVGA screen. The minimum layout size for a small screen
        is approximately 320x426 dp units.  Examples are QVGA low density and VGA high
        density.</li>
        <li><code>normal</code>: Screens that are of similar size to a
        medium-density HVGA screen. The minimum
        layout size for a normal screen is approximately 320x470 dp units.  Examples
        of such screens a WQVGA low density, HVGA medium density, WVGA
        high density.</li>
        <li><code>large</code>: Screens that are of similar size to a
        medium-density VGA screen.
        The minimum layout size for a large screen is approximately 480x640 dp units.
        Examples are VGA and WVGA medium density screens.</li>
        <li><code>xlarge</code>: Screens that are considerably larger than the traditional
        medium-density HVGA screen. The minimum layout size for an xlarge screen
        is approximately 720x960 dp units.  In most cases, devices with extra large
        screens would be too large to carry in a pocket and would most likely
        be tablet-style devices. <em>Added in API level 9.</em></li>
        </ul>
        <p class="note"><strong>Note:</strong> Using a size qualifier does not imply that the
resources are <em>only</em> for screens of that size. If you do not provide alternative
resources with qualifiers that better match the current device configuration, the system may use
whichever resources are the <a href="#BestMatch">best match</a>.</p>
        <p class="caution"><strong>Caution:</strong> If all your resources use a size qualifier that
is <em>larger</em> than the current screen, the system will <strong>not</strong> use them and your
application will crash at runtime (for example, if all layout resources are tagged with the <code>xlarge</code> qualifier, but the device is a normal-size screen).</p>
        <p><em>Added in API level 4.</em></p>
        
        <p>See <a href="../../../guide/practices/screens_support.html">Supporting Multiple
Screens</a> for more information.</p>
        <p>Also see the <code><a href="../../../reference/android/content/res/Configuration.html#screenLayout">screenLayout</a></code> configuration field,
which indicates whether the screen is small, normal,
or large.</p>
      </td>
    </tr>
    <tr id="ScreenAspectQualifier">
      <td>Screen aspect</td>
      <td>
        <code>long</code><br/>
        <code>notlong</code>
      </td>
      <td>
        <ul class="nolist">
          <li><code>long</code>: Long screens, such as WQVGA, WVGA, FWVGA</li>
          <li><code>notlong</code>: Not long screens, such as QVGA, HVGA, and VGA</li>
        </ul>
        <p><em>Added in API level 4.</em></p>
        <p>This is based purely on the aspect ratio of the screen (a "long" screen is wider). This
is not related to the screen orientation.</p>
        <p>Also see the <code><a href="../../../reference/android/content/res/Configuration.html#screenLayout">screenLayout</a></code> configuration field,
which indicates whether the screen is long.</p>
      </td>
    </tr>
    <tr id="OrientationQualifier">
      <td>Screen orientation</td>
      <td>
        <code>port</code><br/>
        <code>land</code>  <!-- <br/>
        <code>square</code>  -->
      </td>
      <td>
        <ul class="nolist">
          <li><code>port</code>: Device is in portrait orientation (vertical)</li>
          <li><code>land</code>: Device is in landscape orientation (horizontal)</li>
          <!-- Square mode is currently not used. -->
        </ul>
        <p>This can change during the life of your application if the user rotates the
screen. See <a href="runtime-changes.html">Handling Runtime Changes</a> for information about
how this affects your application during runtime.</p>
        <p>Also see the <code><a href="../../../reference/android/content/res/Configuration.html#orientation">orientation</a></code> configuration field,
which indicates the current device orientation.</p>
      </td>
    </tr>
    <tr id="DockQualifier">
      <td>Dock mode</td>
      <td>
        <code>car</code><br/>
        <code>desk</code>
      </td>
      <td>
        <ul class="nolist">
          <li><code>car</code>: Device is in a car dock</li>
          <li><code>desk</code>: Device is in a desk dock</li>
        </ul>
        <p><em>Added in API level 8.</em></p>
        <p>This can change during the life of your application if the user places the device in a
dock. You can enable or disable this mode using <code><a href="../../../reference/android/app/UiModeManager.html">UiModeManager</a></code>. See <a href="runtime-changes.html">Handling Runtime Changes</a> for
information about how this affects your application during runtime.</p>
      </td>
    </tr>
    <tr id="NightQualifier">
      <td>Night mode</td>
      <td>
        <code>night</code><br/>
        <code>notnight</code>
      </td>
      <td>
        <ul class="nolist">
          <li><code>night</code>: Night time</li>
          <li><code>notnight</code>: Day time</li>
        </ul>
        <p><em>Added in API level 8.</em></p>
        <p>This can change during the life of your application if night mode is left in
auto mode (default), in which case the mode changes based on the time of day.  You can enable
or disable this mode using <code><a href="../../../reference/android/app/UiModeManager.html">UiModeManager</a></code>. See <a
href="runtime-changes.html">Handling Runtime Changes</a> for information about how this affects your
application during runtime.</p>
      </td>
    </tr>
    <tr id="DensityQualifier">
      <td>Screen pixel density (dpi)</td>
      <td>
        <code>ldpi</code><br/>
        <code>mdpi</code><br/>
        <code>hdpi</code><br/>
        <code>xhdpi</code><br/>
        <code>nodpi</code><br/>
        <code>tvdpi</code>
      </td>
      <td>
        <ul class="nolist">
          <li><code>ldpi</code>: Low-density screens; approximately 120dpi.</li>
          <li><code>mdpi</code>: Medium-density (on traditional HVGA) screens; approximately
160dpi.</li>
          <li><code>hdpi</code>: High-density screens; approximately 240dpi.</li>
          <li><code>xhdpi</code>: Extra high-density screens; approximately 320dpi. <em>Added in API
Level 8</em></li>
          <li><code>nodpi</code>: This can be used for bitmap resources that you do not want to be scaled
to match the device density.</li>
          <li><code>tvdpi</code>: Screens somewhere between mdpi and hdpi; approximately 213dpi. This is
not considered a "primary" density group. It is mostly intended for televisions and most
apps shouldn't need it&mdash;providing mdpi and hdpi resources is sufficient for most apps and
the system will scale them as appropriate. This qualifier was introduced with API level 13.</li>
        </ul>
        <p>There is a 3:4:6:8 scaling ratio between the four primary densities (ignoring the
tvdpi density). So, a 9x9 bitmap in ldpi is 12x12 in mdpi, 18x18 in hdpi and 24x24 in xhdpi.</p>
        <p>If you decide that your image resources don't look good enough on a television or
other certain devices and want to try tvdpi resources, the scaling factor is 1.33*mdpi. For
example, a 100px x 100px image for mdpi screens should be 133px x 133px for tvdpi.</p>
        <p class="note"><strong>Note:</strong> Using a density qualifier does not imply that the
resources are <em>only</em> for screens of that density. If you do not provide alternative
resources with qualifiers that better match the current device configuration, the system may use
whichever resources are the <a href="#BestMatch">best match</a>.</p>
        <p>See <a href="../../../guide/practices/screens_support.html">Supporting Multiple
Screens</a> for more information about how to handle different screen densities and how Android
might scale your bitmaps to fit the current density.</p>
       </td>
    </tr>
    <tr id="TouchscreenQualifier">
      <td>Touchscreen type</td>
      <td>
        <code>notouch</code><br/>
        <code>stylus</code><br/>
        <code>finger</code>
      </td>
      <td>
        <ul class="nolist">
          <li><code>notouch</code>: Device does not have a touchscreen.</li>
          <li><code>stylus</code>: Device has a resistive touchscreen that's suited for use with a
stylus.</li>
          <li><code>finger</code>: Device has a touchscreen.</li>
        </ul>
        <p>Also see the <code><a href="../../../reference/android/content/res/Configuration.html#touchscreen">touchscreen</a></code> configuration field,
which indicates the type of touchscreen on the device.</p>
      </td>
    </tr>
    <tr id="KeyboardAvailQualifier">
      <td>Keyboard availability</td>
      <td>
        <code>keysexposed</code><br/>
        <code>keyshidden</code><br/>
        <code>keyssoft</code>
      </td>
      <td>
        <ul class="nolist">
          <li><code>keysexposed</code>: Device has a keyboard available. If the device has a
software keyboard enabled (which is likely), this may be used even when the hardware keyboard is
<em>not</em> exposed to the user, even if the device has no hardware keyboard. If no software
keyboard is provided or it's disabled, then this is only used when a hardware keyboard is
exposed.</li>
          <li><code>keyshidden</code>: Device has a hardware keyboard available but it is
hidden <em>and</em> the device does <em>not</em> have a software keyboard enabled.</li>
          <li><code>keyssoft</code>: Device has a software keyboard enabled, whether it's
visible or not.</li>
        </ul>
        <p>If you provide <code>keysexposed</code> resources, but not <code>keyssoft</code>
resources, the system uses the <code>keysexposed</code> resources regardless of whether a
keyboard is visible, as long as the system has a software keyboard enabled.</p>
        <p>This can change during the life of your application if the user opens a hardware
keyboard. See <a href="runtime-changes.html">Handling Runtime Changes</a> for information about how
this affects your application during runtime.</p>
        <p>Also see the configuration fields <code><a href="../../../reference/android/content/res/Configuration.html#hardKeyboardHidden">hardKeyboardHidden</a></code> and <code><a href="../../../reference/android/content/res/Configuration.html#keyboardHidden">keyboardHidden</a></code>, which indicate the visibility of a hardware
keyboard and and the visibility of any kind of keyboard (including software), respectively.</p>
      </td>
    </tr>
    <tr id="ImeQualifier">
      <td>Primary text input method</td>
      <td>
        <code>nokeys</code><br/>
        <code>qwerty</code><br/>
        <code>12key</code>
      </td>
      <td>
        <ul class="nolist">
          <li><code>nokeys</code>: Device has no hardware keys for text input.</li>
          <li><code>qwerty</code>: Device has a hardware qwerty keyboard, whether it's visible to the
user
or not.</li>
          <li><code>12key</code>: Device has a hardware 12-key keyboard, whether it's visible to the user
or not.</li>
        </ul>
        <p>Also see the <code><a href="../../../reference/android/content/res/Configuration.html#keyboard">keyboard</a></code> configuration field,
which indicates the primary text input method available.</p>
      </td>
    </tr>
    <tr id="NavAvailQualifier">
      <td>Navigation key availability</td>
      <td>
        <code>navexposed</code><br/>
        <code>navhidden</code>
      </td>
      <td>
        <ul class="nolist">
          <li><code>navexposed</code>: Navigation keys are available to the user.</li>
          <li><code>navhidden</code>: Navigation keys are not available (such as behind a closed
lid).</li>
        </ul>
        <p>This can change during the life of your application if the user reveals the navigation
keys. See <a href="runtime-changes.html">Handling Runtime Changes</a> for
information about how this affects your application during runtime.</p>
        <p>Also see the <code><a href="../../../reference/android/content/res/Configuration.html#navigationHidden">navigationHidden</a></code> configuration
field, which indicates whether navigation keys are hidden.</p>
      </td>
    </tr>
    <tr id="TouchQualifier">
      <td>Primary non-touch navigation method</td>
      <td>
        <code>nonav</code><br/>
        <code>dpad</code><br/>
        <code>trackball</code><br/>
        <code>wheel</code>
      </td>
      <td>
        <ul class="nolist">
          <li><code>nonav</code>: Device has no navigation facility other than using the
touchscreen.</li>
          <li><code>dpad</code>: Device has a directional-pad (d-pad) for navigation.</li>
          <li><code>trackball</code>: Device has a trackball for navigation.</li>
          <li><code>wheel</code>: Device has a directional wheel(s) for navigation (uncommon).</li>
        </ul>
        <p>Also see the <code><a href="../../../reference/android/content/res/Configuration.html#navigation">navigation</a></code> configuration field,
which indicates the type of navigation method available.</p>
      </td>
    </tr>
<!-- DEPRECATED
    <tr>
      <td>Screen dimensions</td>
      <td>Examples:<br/>
        <code>320x240</code><br/>
        <code>640x480</code><br/>
        etc.
      </td>
      <td>
        <p>The larger dimension must be specified first. <strong>This configuration is deprecated
and should not be used</strong>. Instead use "screen size," "wider/taller screens," and "screen
orientation" described above.</p>
      </td>
    </tr>
-->
    <tr id="VersionQualifier">
      <td>Platform Version (API level)</td>
      <td>Examples:<br/>
        <code>v3</code><br/>
        <code>v4</code><br/>
        <code>v7</code><br/>
        etc.</td>
      <td>
        <p>The API level supported by the device. For example, <code>v1</code> for API level
1 (devices with Android 1.0 or higher) and <code>v4</code> for API level 4 (devices with Android
1.6 or higher). See the <a
href="../../../guide/appendix/api-levels.html">Android API levels</a> document for more information
about these values.</p>
        <p class="caution"><strong>Caution:</strong> Android 1.5 and 1.6 only match resources
with this qualifier when it exactly matches the platform version. See the section below about <a
href="#KnownIssues">Known Issues</a> for more information.</p>
      </td>
    </tr>
</table>


<h3 id="QualifierRules">Qualifier name rules</h3>

<p>Here are some rules about using configuration qualifier names:</p>

<ul>
    <li>You can specify multiple qualifiers for a single set of resources, separated by dashes. For
example, <code>drawable-en-rUS-land</code> applies to US-English devices in landscape
orientation.</li>
    <li>The qualifiers must be in the order listed in <a href="#table2">table 2</a>. For
example:
      <ul>
        <li>Wrong: <code>drawable-hdpi-port/</code></li>
        <li>Correct: <code>drawable-port-hdpi/</code></li>
      </ul>
    </li>
    <li>Alternative resource directories cannot be nested. For example, you cannot have
<code>res/drawable/drawable-en/</code>.</li>
    <li>Values are case-insensitive.  The resource compiler converts directory names
    to lower case before processing to avoid problems on case-insensitive
    file systems. Any capitalization in the names is only to benefit readability.</li>
    <li>Only one value for each qualifier type is supported. For example, if you want to use
the same drawable files for Spain and France, you <em>cannot</em> have a directory named
<code>drawable-rES-rFR/</code>. Instead you need two resource directories, such as
<code>drawable-rES/</code> and <code>drawable-rFR/</code>, which contain the appropriate files.
However, you are not required to actually duplicate the same files in both locations. Instead, you
can create an alias to a resource. See <a href="#AliasResources">Creating
alias resources</a> below.</li>
</ul>

<p>After you save alternative resources into directories named with
these qualifiers, Android automatically applies the resources in your application based on the
current device configuration. Each time a resource is requested, Android checks for alternative
resource directories that contain the requested resource file, then <a href="#BestMatch">finds the
best-matching resource</a> (discussed below). If there are no alternative resources that match
a particular device configuration, then Android uses the corresponding default resources (the
set of resources for a particular resource type that does not include a configuration
qualifier).</p>



<h3 id="AliasResources">Creating alias resources</h3>

<p>When you have a resource that you'd like to use for more than one device
configuration (but do not want to provide as a default resource), you do not need to put the same
resource in more than one alternative resource directory. Instead, you can (in some cases) create an
alternative
resource that acts as an alias for a resource saved in your default resource directory.</p>

<p class="note"><strong>Note:</strong> Not all resources offer a mechanism by which you can
create an alias to another resource. In particular, animation, menu, raw, and other unspecified
resources in the <code>xml/</code> directory do not offer this feature.</p>

<p>For example, imagine you have an application icon, <code>icon.png</code>, and need unique version of
it for different locales. However, two locales, English-Canadian and French-Canadian, need to
use the same version. You might assume that you need to copy the same image
into the resource directory for both English-Canadian and French-Canadian, but it's
not true. Instead, you can save the image that's used for both as <code>icon_ca.png</code> (any
name other than <code>icon.png</code>) and put
it in the default <code>res/drawable/</code> directory. Then create an <code>icon.xml</code> file in <code>res/drawable-en-rCA/</code> and <code>res/drawable-fr-rCA/</code> that refers to the <code>icon_ca.png</code>
resource using the <code>&lt;bitmap&gt;</code> element. This allows you to store just one version of the
PNG file and two small XML files that point to it. (An example XML file is shown below.)</p>


<h4>Drawable</h4>

<p>To create an alias to an existing drawable, use the <code>&lt;bitmap&gt;</code> element.
For example:</p>

<pre>
&lt;?xml version="1.0" encoding="utf-8"?>
&lt;bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/icon_ca" />
</pre>

<p>If you save this file as <code>icon.xml</code> (in an alternative resource directory, such as
<code>res/drawable-en-rCA/</code>), it is compiled into a resource that you
can reference as <code>R.drawable.icon</code>, but is actually an alias for the <code>R.drawable.icon_ca</code> resource (which is saved in <code>res/drawable/</code>).</p>


<h4>Layout</h4>

<p>To create an alias to an existing layout, use the <code>&lt;include&gt;</code>
element, wrapped in a <code>&lt;merge&gt;</code>. For example:</p>

<pre>
&lt;?xml version="1.0" encoding="utf-8"?>
&lt;merge>
    &lt;include layout="@layout/main_ltr"/>
&lt;/merge>
</pre>

<p>If you save this file as <code>main.xml</code>, it is compiled into a resource you can reference
as <code>R.layout.main</code>, but is actually an alias for the <code>R.layout.main_ltr</code>
resource.</p>


<h4>Strings and other simple values</h4>

<p>To create an alias to an existing string, simply use the resource ID of the desired
string as the value for the new string. For example:</p>

<pre>
&lt;?xml version="1.0" encoding="utf-8"?>
&lt;resources>
    &lt;string name="hello">Hello&lt;/string>
    &lt;string name="hi">@string/hello&lt;/string>
&lt;/resources>
</pre>

<p>The <code>R.string.hi</code> resource is now an alias for the <code>R.string.hello</code>.</p>

<p> <a href="../../../guide/topics/resources/more-resources.html">Other simple values</a> work the
same way. For example, a color:</p>

<pre>
&lt;?xml version="1.0" encoding="utf-8"?>
&lt;resources>
    &lt;color name="yellow">#f00&lt;/color>
    &lt;color name="highlight">@color/red&lt;/color>
&lt;/resources>
</pre>




<h2 id="Compatibility">Providing the Best Device Compatibility with Resources</h2>

<p>In order for your application to support multiple device configurations, it's very important that
you always provide default resources for each type of resource that your application uses.</p>

<p>For example, if your application supports several languages, always include a <code>values/</code> directory (in which your strings are saved) <em>without</em> a <a
href="#LocaleQualifier">language and region qualifier</a>. If you instead put all your string files
in directories that have a language and region qualifier, then your application will crash when run
on a device set to a language that your strings do not support. But, as long as you provide default
<code>values/</code> resources, then your application will run properly (even if the user doesn't
understand that language&mdash;it's better than crashing).</p>

<p>Likewise, if you provide different layout resources based on the screen orientation, you should
pick one orientation as your default. For example, instead of providing layout resources in <code>layout-land/</code> for landscape and <code>layout-port/</code> for portrait, leave one as the default, such as
<code>layout/</code> for landscape and <code>layout-port/</code> for portrait.</p>

<p>Providing default resources is important not only because your application might run on a
configuration you had not anticipated, but also because new versions of Android sometimes add
configuration qualifiers that older versions do not support. If you use a new resource qualifier,
but maintain code compatibility with older versions of Android, then when an older version of
Android runs your application, it will crash if you do not provide default resources, because it
cannot use the resources named with the new qualifier. For example, if your <a
href="../../../guide/topics/manifest/uses-sdk-element.html#min"><code>minSdkVersion</code></a> is set to 4, and you qualify all of your drawable resources using <a
href="#NightQualifier">night mode</a> (<code>night</code> or <code>notnight</code>, which were added in API
Level 8), then an API level 4 device cannot access your drawable resources and will crash. In this
case, you probably want <code>notnight</code> to be your default resources, so you should exclude that
qualifier so your drawable resources are in either <code>drawable/</code> or <code>drawable-night/</code>.</p>

<p>So, in order to provide the best device compatibility, always provide default
resources for the resources your application needs to perform properly. Then create alternative
resources for specific device configurations using the configuration qualifiers.</p>

<p>There is one exception to this rule: If your application's <a
href="../../../guide/topics/manifest/uses-sdk-element.html#min"><code>minSdkVersion</code></a> is 4 or
greater, you <em>do not</em> need default drawable resources when you provide alternative drawable
resources with the <a href="#DensityQualifier">screen density</a> qualifier. Even without default
drawable resources, Android can find the best match among the alternative screen densities and scale
the bitmaps as necessary. However, for the best experience on all types of devices, you should
provide alternative drawables for all three types of density. If your <a
href="../../../guide/topics/manifest/uses-sdk-element.html#min"><code>minSdkVersion</code></a> is
<em>less than</em> 4 (Android 1.5 or lower), be aware that the screen size, density, and aspect
qualifiers are not supported on Android 1.5 or lower, so you might need to perform additional
compatibility for these versions.</p>


<h3 id="ScreenCompatibility">Providing screen resource compatibility for Android 1.5</h3>

<p>Android 1.5 (and lower) does not support the following configuration qualifers:</p>
<dl>
  <dt><a href="#DensityQualifier">Density</a></dt>
    <dd><code>ldpi</code>, <code>mdpi</code>, <code>ldpi</code>, and <code>nodpi</code></dd>
  <dt><a href="#ScreenSizeQualifier">Screen size</a></dt>
    <dd><code>small</code>, <code>normal</code>, and <code>large</code></dd>
  <dt><a href="#ScreenAspectQualifier">Screen aspect</a></dt>
    <dd><code>long</code> and <code>notlong</code></dd>
</dl>

<p>These configuration qualifiers were introduced in Android 1.6, so Android 1.5 (API level 3) and
lower does not support them. If you use these configuration qualifiers and do not provide
corresponding default resources, then an Android 1.5 device might use any one of the resource
directories named with the above screen configuration qualifiers, because it ignores these
qualifiers and uses whichever otherwise-matching drawable resource it finds first.</p>

<p>For example, if your application supports Android 1.5 and includes drawable resources for
each density type (<code>drawable-ldpi/</code>, <code>drawable-mdpi/</code>, and <code>drawable-ldpi/</code>),
and does <em>not</em> include default drawable resources (<code>drawable/</code>), then
an Android 1.5 will use drawables from any one of the alternative resource directories, which
can result in a user interface that's less than ideal.<p>

<p>So, to provide compatibility with Android 1.5 (and lower) when using the screen configuration
qualifiers:</p>
<ol>
  <li>Provide default resources that are for medium-density, normal, and notlong screens.

    <p>Because all Android 1.5 devices have medium-density, normal, not-long screens, you can
place these kinds of resources in the corresponding default resource directory. For example, put all
medium density drawable resources in <code>drawable/</code> (instead of <code>drawable-mdpi/</code>),
put <code>normal</code> size resources in the corresponding default resource directory, and <code>notlong</code> resources in the corresponding default resource directory.</p>
  </li>

  <li>Ensure that your <a href="../../../sdk/tools-notes.html">SDK Tools</a> version
is r6 or greater.

    <p>You need SDK Tools, Revision 6 (or greater), because it includes a new packaging tool that
automatically applies an appropriate <a href="#VersionQualifier">version qualifier</a> to any
resource directory named with a qualifier that does not exist in Android 1.0. For example, because
the density qualifier was introduced in Android 1.6 (API level 4), when the packaging tool
encounters a resource directory using the density qualifier, it adds <code>v4</code> to the directory
name to ensure that older versions do not use those resources (only API level 4 and higher support
that qualifier). Thus, by putting your medium-density resources in a directory <em>without</em> the
<code>mdpi</code> qualifier, they are still accessible by Android 1.5, and any device that supports the
density qualifer and has a medium-density screen also uses the default resources (which are mdpi)
because they are the best match for the device (instead of using the <code>ldpi</code> or <code>hdpi</code>
resources).</p>
</li>
</ol>

<p class="note"><strong>Note:</strong> Later versions of Android, such as API level 8,
introduce other configuration qualifiers that older version do not support. To provide the best
compatibility, you should always include a set of default resources for each type of resource
that your application uses, as discussed above to provide the best device compatibility.</p>



<h2 id="BestMatch">How Android Finds the Best-matching Resource</h2>

<p>When you request a resource for which you provide alternatives, Android selects which
alternative resource to use at runtime, depending on the current device configuration. To
demonstrate how Android selects an alternative resource, assume the following drawable directories
each contain different versions of the same images:</p>

<pre class="classic no-pretty-print">
drawable/
drawable-en/
drawable-fr-rCA/
drawable-en-port/
drawable-en-notouch-12key/
drawable-port-ldpi/
drawable-port-notouch-12key/
</pre>

<p>And assume the following is the device configuration:</p>

<p style="margin-left:1em;">
Locale = <code>en-GB</code> <br/>
Screen orientation = <code>port</code> <br/>
Screen pixel density = <code>hdpi</code> <br/>
Touchscreen type = <code>notouch</code> <br/>
Primary text input method = <code>12key</code>
</p>

<p>By comparing the device configuration to the available alternative resources, Android selects
drawables from <code>drawable-en-port</code>.</p>

<p>The system arrives at its decision for which resources to use with the following
logic:</p>


<div class="figure" style="width:280px">
<img src="../../../images/resources/res-selection-flowchart.png" alt="" height="590" />
<p class="img-caption"><strong>Figure 2.</strong> Flowchart of how Android finds the
best-matching resource.</p>
</div>


<ol>
  <li>Eliminate resource files that contradict the device configuration.
    <p>The <code>drawable-fr-rCA/</code> directory is eliminated, because it
contradicts the <code>en-GB</code> locale.</p>
<pre class="classic no-pretty-print">
drawable/
drawable-en/
<strike>drawable-fr-rCA/</strike>
drawable-en-port/
drawable-en-notouch-12key/
drawable-port-ldpi/
drawable-port-notouch-12key/
</pre>
<p class="note"><strong>Exception:</strong> Screen pixel density is the one qualifier that is not
eliminated due to a contradiction. Even though the screen density of the device is hdpi,
<code>drawable-port-ldpi/</code> is not eliminated because every screen density is
considered to be a match at this point. More information is available in the <a
href="../../../guide/practices/screens_support.html">Supporting Multiple
Screens</a> document.</p></li>

  <li>Pick the (next) highest-precedence qualifier in the list (<a href="#table2">table 2</a>).
(Start with MCC, then move down.) </li>
  <li>Do any of the resource directories include this qualifier?  </li>
    <ul>
      <li>If No, return to step 2 and look at the next qualifier. (In the example,
  the answer is &quot;no&quot; until the language qualifier is reached.)</li>
      <li>If Yes, continue to step 4.</li>
    </ul>
  </li>

  <li>Eliminate resource directories that do not include this qualifier. In the example, the system
eliminates all the directories that do not include a language qualifier:</li>
<pre class="classic no-pretty-print">
<strike>drawable/</strike>
drawable-en/
drawable-en-port/
drawable-en-notouch-12key/
<strike>drawable-port-ldpi/</strike>
<strike>drawable-port-notouch-12key/</strike>
</pre>
<p class="note"><strong>Exception:</strong> If the qualifier in question is screen pixel density,
Android selects the option that most closely matches the device screen density.
In general, Android prefers scaling down a larger original image to scaling up a smaller
original image. See <a href="../../../guide/practices/screens_support.html">Supporting Multiple
Screens</a>.</p>
  </li>

  <li>Go back and repeat steps 2, 3, and 4 until only one directory remains. In the example, screen
orientation is the next qualifier for which there are any matches.
So, resources that do not specify a screen orientation are eliminated:
<pre class="classic no-pretty-print">
<strike>drawable-en/</strike>
drawable-en-port/
<strike>drawable-en-notouch-12key/</strike>
</pre>
<p>The remaining directory is <code>drawable-en-port</code>.</p>
  </li>
</ol>

<p>Though this procedure is executed for each resource requested, the system further optimizes
some aspects. One such optimization is that once the device configuration is known, it might
eliminate alternative resources that can never match. For example, if the configuration
language is English ("en"), then any resource directory that has a language qualifier set to
something other than English is never included in the pool of resources checked (though a
resource directory <em>without</em> the language qualifier is still included).</p>

<p>When selecting resources based on the screen size qualifiers, the system will use resources
designed for a screen smaller than the current screen if there are no resources that better match
(for example, a large-size screen will use normal-size screen resources if necessary). However, if
the only available resources are <em>larger</em> than the current screen, the system will
<strong>not</strong> use them and your application will crash if no other resources match the device
configuration (for example, if all layout resources are tagged with the <code>xlarge</code> qualifier,
but the device is a normal-size screen).</p>

<p class="note"><strong>Note:</strong> The <em>precedence</em> of the qualifier (in <a
href="#table2">table 2</a>) is more important
than the number of qualifiers that exactly match the device. For example, in step 4 above, the last
choice on the list includes three qualifiers that exactly match the device (orientation, touchscreen
type, and input method), while <code>drawable-en</code> has only one parameter that matches
(language). However, language has a higher precedence than these other qualifiers, so
<code>drawable-port-notouch-12key</code> is out.</p>

<p>To learn more about how to use resources in your application, continue to <a
href="accessing-resources.html">Accessing Resources</a>.</p>




<h2 id="KnownIssues">Known Issues</h2>

<h3>Android 1.5 and 1.6: Version qualifier performs exact match, instead of best match</h3>

<p>The correct behavior is for the system to match resources marked with a <a
href="#VersionQualifier">version qualifier</a> equal
to or less than the platform version on the device, but on Android 1.5 and 1.6, (API level 3 and 4),
there is a bug that causes the system to match resources marked with the version qualifier
only when it exactly matches the version on the device.</p>

<p><b>The workaround:</b> To provide version-specific resources, abide by this behavior. However,
because this bug is fixed in versions of Android available after 1.6, if
you need to differentiate resources between Android 1.5, 1.6, and later versions, then you only need
to apply the version qualifier to the 1.6 resources and one to match all later versions. Thus, this
is effectively a non-issue.</p>

<p>For example, if you want drawable resources that are different on each Android 1.5, 1.6,
and 2.0.1 (and later), create three drawable directories: <code>drawable/</code> (for 1.5 and lower),
<code>drawable-v4</code> (for 1.6), and <code>drawable-v6</code> (for 2.0.1 and later&mdash;version 2.0, v5,
is no longer available).</p>



    </div>

  <a href="#top" style="float:right">&uarr; Go to top</a>
  
    <p><a href="index.html">&larr; Back to Application Resources</a></p>
  
  </div>

<div id="footer">


  <div id="copyright">
    
  Except as noted, this content is licensed under <a
  href="http://www.apache.org/licenses/LICENSE-2.0">Apache 2.0</a>. 
  For details and restrictions, see the <a href="../../../license.html">
  Content License</a>.
  </div>
  <div id="build_info">
    
  Android 4.0&nbsp;r1 - 17 Oct 2011 18:17

  </div>

  <div id="footerlinks">
    
  <p>
    <a href="http://www.android.com/terms.html">Site Terms of Service</a> -
    <a href="http://www.android.com/privacy.html">Privacy Policy</a> -
    <a href="http://www.android.com/branding.html">Brand Guidelines</a>
  </p>
  </div>

</div> <!-- end footer -->

</div><!-- end doc-content -->

</div> <!-- end body-content --> 

<script type="text/javascript">
init(); /* initialize android-developer-docs.js */
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-5831155-1");
pageTracker._trackPageview();
</script>

</body>
</html>



